package cn.itcast.repository;

import cn.itcast.bean.HotWords;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description :
 * @Auther : zj
 * @Date : 2019/1/21 13:58
 */
@Repository
public class TestRepository {
    @Autowired
    private MongoTemplate mongoTemplate;

    public List<HotWords> hotwordsListByConf(List<String> ids) {
        Query query = new Query();
        query.addCriteria(Criteria.where("_id").in(ids));
        return mongoTemplate.find(query, HotWords.class);
    }

    public List<HotWords> hotwordsList(int type) {
        Query query = new Query();
        query.addCriteria(Criteria.where("type").is(type));
        query.with(new Sort(Sort.Direction.ASC, "order"));
        return mongoTemplate.find(query, HotWords.class);
    }


}
